package org.dromara.comm_lhz.controller;

import org.dromara.comm_lhz.entity.AsActivityEntity;
import org.dromara.comm_lhz.entity.dto.AsActivityDto;
import org.dromara.comm_lhz.mapper.AsActivityImgHMapper;
import org.dromara.comm_lhz.service.AsActivityHService;
import org.dromara.comm_lhz.util.QiniuUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 社区活动控制器
 */
@RestController
@RequestMapping("/activity")
public class AsActivityHController {

    @Autowired
    private AsActivityHService asActivityHService;

    @Autowired
    private AsActivityImgHMapper asActivityImgHMapper;

    @Autowired
    private QiniuUtil qiniuUtil;

    /**
     * 查询社区活动信息
     * @param keyword 搜索关键字
     * @param state 活动状态
     * @param timePeriod 时间段
     * @return 社区活动信息
     */
    @GetMapping("/selActivityInfo")
    public ResponseEntity<Object> selActivityInfo(String keyword, Integer state, String timePeriod, Pageable pageable){
        return new ResponseEntity<>(asActivityHService.selActivityInfo(keyword, state, timePeriod,pageable), HttpStatus.OK);
    }

    /**
     * 添加社区活动信息
     * @param asActivityDto 社区活动数据传输对象
     */
    @PostMapping("/addActivityInfo")
    public void addActivityInfo(@RequestBody AsActivityDto asActivityDto ){
        asActivityHService.addActivityInfo(asActivityDto);
    }

    /**
     * 根据id修改社区活动信息
     * @param asActivityDto 社区活动实体
     * @return 修改结果
     */
    @PostMapping("/updateActivityInfoById")
    public void updateActivityInfoById(@RequestBody AsActivityDto asActivityDto){
        asActivityHService.updateActivityInfo(asActivityDto);
    }

    /**
     * 根据id删除社区活动信息
     * @param id 社区活动ID
     * @return 删除结果
     */
    @GetMapping("/deleteActivityInfoById")
    public ResponseEntity<Object> deleteActivityInfoById(Long id){
        return new ResponseEntity<>(asActivityHService.removeById(id), HttpStatus.OK);
    }

}
